#coding=utf-8
import math

def memory(t,count):
    k=2.72
    h=1.075
    n=0.2639
    if count>0:
        kern=math.log(count/2.5+2)
        k=k*math.log(count/2.5+2)
        y=100*k/(h/(kern+2)*math.log(n*t+1)+k)
    else:
        y=100*k/(h*math.log(n*t+1)+k)
    return y
def reallearn(losth,t,count):
    y=memory(t,count-0.8)
    if y>losth:
        return False,round(count,4)
    else:
        delta_lost=losth-y
        totual_lost=losth-(21+count)
        if delta_lost>totual_lost:
            return True,0
        lostradio=delta_lost/totual_lost
        #count=(1-math.sin(lostradio*math.pi/2))*count
        count=(1-lostradio)*count
        return True,round(count,4)

def readtime(mintime):
    if mintime<60:
        return "{}min".format(mintime)
    elif mintime<60*24:
        return "{}hours".format(round(mintime/64,2))
    else:
        return "{}days".format(round(mintime/64/24,2))
if __name__=='__main__':
    # xlist=[]
    # ylist=[]
    # for i in range(1,2000):
    #     xlist.append(i)
    #     ylist.append(memory(i))
    # showpot(xlist, ylist)
    for learntimes in range(1,20):
        for t in [0,1,20,60,60*8.5,60*24,60*48,60*24*6,60*24*30,60*24*300]:
            flag,ncount=reallearn(71.8,t,learntimes)
            print(readtime(t),learntimes,flag,ncount)
        # xlist=[]
        # ylist=[]
    #     for i in [0,20,60,60*8.5,60*24,60*48,60*24*6,60*24*30]:
    #         xlist.append(i)
    #         ylist.append(memory(i,learntimes))
            
    #     showpot(xlist, ylist,"learntimes={}".format(learntimes))


    # def active_losth(Lengh):
    #     if Lengh<3:
    #         return 61.8
    #     elif Lengh>12:
    #         return 71.8
    #     else:
    #         return round((Lengh-3)/9*10+61.8,4)

    


    # for i in range(5,12):
    #     learntimes=0
    #     passtime=1
    #     losthp=active_losth(i)
    #     print(losthp)
    #     while learntimes<15:
    #         flag,newcount=reallearn(losthp,passtime,learntimes)
    #         if flag:
    #             learntimes+=1
    #             print(losthp,readtime(passtime),learntimes)
    #         passtime+=1
